<template>
    <el-container>
        <el-header style="background-color: #e62263;">
        <div class="header-box" style="width:80%;margin:auto;padding: 10px;">
            <div class="block" style="float: left;"><el-avatar shape="square" :size="40" :src="this.userData.img"></el-avatar></div>
            <div class="block" style="float: right;color: #fff; ">
            <span style="font-size: 14px;">欢迎~</span><span style="font-size: 14px;" >{{this.userData.name}}</span><span style="margin-left: 20px;font-size: 14px;cursor:pointer;" @click="exit()">退出登录</span>
            </div>
        </div>
        </el-header>
      </el-container>
</template>


<script>
export default {

    data() {
      return {

        userData:[],


      }},

    mounted:function(){
    this.loadexecution();
    },

    methods: {

        async loadexecution(){

        const {data:res} = await this.$http.post('user/getUserEmail',this.$qs.stringify({email:JSON.parse(localStorage.getItem('email'))}));
        if(res.success==false){
        alert("当前用户登录异常!请重新登录")
        localStorage.setItem('email','');
        this.$router.push({path: '/Login'});}
        else{
            this.userData = res.result;
            console.log(this.userData);
        }            

    },

    exit()
    {
        localStorage.setItem('email','');
        this.$router.push({path: '/Login'})
    }  
}  
       }
</script>